package com.interactive.internal.ant;

/**
 * Holds the eval timebomb code so that we can use BCEL to suck it out
 * of this class and inject it into another.
 *
 * @author Ben Rady
 * @version 1.0
 */
public class BombSquadVan
{
  public static final long EXPIRE_TIMESTAMP = 0;
  public static final String INT_PRODUCT_NAME = "Unknown";

  static
  {
    // ========================================================================
    // date expiration patch
    // ========================================================================

    // Array of month names
    String[] months =
        {
        "January", "February", "March", "April", "May",
        "June", "July", "August", "September", "October",
        "November", "December"
    };

    // set expire month and year vars
    java.util.Calendar expDate = java.util.Calendar.getInstance();
    expDate.setTimeInMillis(EXPIRE_TIMESTAMP);
    int expire_day = expDate.get(java.util.Calendar.DAY_OF_MONTH);
    int expire_year = expDate.get(java.util.Calendar.YEAR) + 1;
    int expire_month = expDate.get(java.util.Calendar.MONTH);

    // get the current month and year
    java.util.Calendar current = java.util.Calendar.getInstance();
    int year = current.get(java.util.Calendar.YEAR);
    int month = current.get(java.util.Calendar.MONTH) + 1;
    int day = current.get(java.util.Calendar.DAY_OF_MONTH);

    // make a string of the expiration date
    String expiration_date = new String(expire_day + "-"
                                        + months[(expire_month - 1)] + "-" +
                                        expire_year);

    // quit if the date is bogus, else notify the user when the
    // evaluation will end
    //
    // NOTE: The evaluation now expires on a specific day
    //
    if ((year > expire_year) ||
        ((year == expire_year) && (month > expire_month)) ||
        ((year == expire_year) && (month == expire_month) &&
         (day > expire_day)))
    {
      System.out.println("*** " + INT_PRODUCT_NAME +
                         "'s Evaluation period expired "
                         + expiration_date + " ***");
      System.out.println("Exiting Program");
      System.out.println("");
      System.exit(255);
    }
    else
    {
      System.out.println("NOTICE: " + INT_PRODUCT_NAME +
                         "'s Evaluation period ends " +
                         expiration_date);
      System.out.println("");
    }

  } // end-static initialization code for Standard Product Initializer

}
